<template>
  <div class="detail-shop" v-if="shopInfo">
    <!-- 头部 -->
    <div class="detail-header">
      <div class="header-bg">
        <img :src="shopInfo.rst.scheme" alt="">
      </div>
      <div class="detail-back">
        <i class="fa fa-chevron-left" @click="goHome"></i>
      </div>
      <div class="detail-logo">
        <img :src="shopInfo.rst.image_path" alt="">
      </div>
    </div>

    <!-- 商家信息 -->
    <div class="detail-title" @click="showDialog=true">
      <span>{{shopInfo.rst.name}}</span>
      <i class="fa fa-caret-right"></i>
    </div>
    <!-- 弹窗 -->
    <detail-dialog :rst="shopInfo.rst" :showDialog="showDialog" @changeShowDialog="showDialog= false" />

    <!-- 详情信息 -->
    <div class="detail-text">
      <span>评分{{shopInfo.rst.rating}}</span>
      <span>月售{{shopInfo.rst.recent_order_num}}单</span>
      <span>蜂鸟专送约{{shopInfo.rst.order_lead_time}}单</span>
    </div>

    <!-- 优惠 -->
    <discount :InfoData="shopInfo.rst.activities" />

    <!-- 公告区 -->
    <div class="announcement">公告{{shopInfo.rst.promotion_info}}
    </div>
    <!-- 导航 -->
    <nav-bar />
    <keep-alive>
      <router-view></router-view>
    </keep-alive>
  </div>
</template>

<script>
import DetailDialog from '@/components/DetailDialog'
import Discount from '@/components/Discount'
import NavBar from '@/views/DetailShop/NavBar'

export default {
  name: 'DatailShop',
  data() {
    return {
      shopInfo: null,
      showDialog: false
    }
  },
  created() {
    this.getData()
  },
  methods: {
    getData() {
      this.$http('/api/profile/batch_shop').then(res => {
        this.shopInfo = res.data
      })
    },
    goHome() {
      this.$router.push('/home')
    }
  },
  components: {
    DetailDialog,
    Discount,
    NavBar
  }
}
</script>

<style lang="less" scoped>
.detail-shop {
  position: relative;
  height: 100%;
  .detail-header {
    .header-bg {
      img {
        width: 100%;
      }
    }
    .detail-back {
      position: absolute;
      top: 8px;
      left: 8px;
      color: #fff;
    }
    .detail-logo {
      position: absolute;
      top: 87px;
      left: 50%;
      transform: translate(-50%, 0);
      width: 70px;
      height: 70px;
      img {
        width: 100%;
      }
    }
  }
  .detail-title {
    padding: 40px 10px 5px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    background-color: #fff;
    span {
      display: inline-block;
      width: 280px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
  .detail-text {
    text-align: center;
    font-size: 12px;
    color: #666;
    background-color: #fff;
    padding-top: 5px;
    span {
      margin-right: 5px;
    }
  }
  .announcement {
    background-color: #fff;
    font-size: 12px;
    color: #666;
    padding: 10px 0 8px 30px;
  }
}
</style>
